package net.aiion.weave.impl.web.servlet.http;

import java.util.logging.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import net.aiion.weave.spi.startup.Startup;

@WebListener
public class WeaveServletContextListener implements ServletContextListener
{
    private static final Logger LOGGER = Logger.getLogger(WeaveServletContextListener.class.getName());

    public WeaveServletContextListener() {
    }

    @Override
    public void contextInitialized(final ServletContextEvent aServletContextEvent) {
        LOGGER.info("WeaveFramework: Starting up.");
        Startup.getInstance().usingGlobalContext();
    }

    @Override
    public void contextDestroyed(final ServletContextEvent aServletContextEvent) {
        LOGGER.info("WeaveFramework: Shutting down.");
        Startup.getInstance().usingGlobalContext().executeShutdown();
    }
}
